package edu.mtu.citizenscience.cs.notepad.model.note;

import java.util.Date;

import com.openswimsoftware.orm.model.Model;
import com.openswimsoftware.orm.model.annotation.Parent;

import android.content.Context;

import edu.mtu.citizenscience.cs.notepad.model.ModelNote;
/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Model of an location in the app DB
 * has a longitude, latitude, and date taken
 * It also belongs to a note
 */
public class ModelLocation extends Model<ModelLocation> {
	// date time the location was taken
	private Date date;
	// the location latitude
	private double latitude;
	// the location longitude
	private double longitude;
	
	// the location's parent note
	@Parent
	private ModelNote note;
	
	/**
	 * Create the location model
	 * 
	 * @param   context - Context - context for model operations
	 * @return	void
	 */
	public ModelLocation(Context context) 
	{
		super(context, ModelLocation.class);
	}

	/**
	 * Create the location model
	 * 
	 * @param   context - Context - context for model operations
	 * @param	id - long - the model id to load from the DB
	 * @return	void
	 */
	public ModelLocation(Context context, long id) 
	{
		super(context, ModelLocation.class, id);
	}
	
	/**
	 * Get the location's parent note
	 * 
	 * @param   void
	 * @return	ModelNote - The locations parent note
	 */
	public ModelNote getNote()
	{
		// make sure the model is loaded
		this.load();
		
		return this.note;
	}
	
	/**
	 * Set the recording's parent note
	 * 
	 * @param   note - ModelNote - The locations parent note
	 * @return	void
	 */
	public void setNote(ModelNote note)
	{
		// mark the model as updated
		this.updated = true;
		
		this.note = note;
	}
	
	/**
	 * Get the location's date
	 * 
	 * @param   void
	 * @return	Date - The locations date
	 */
	public Date getDate()
	{
		// make sure the model is loaded
		this.load();
		
		return this.date;
	}
	
	/**
	 * Set the location's date
	 * 
	 * @param   date - Date - The locations date
	 * @return	void
	 */
	public void setDate(Date date)
	{
		// mark the model as updated
		this.updated = true;
		
		this.date = date;
	}

	/**
	 * Get the location's latitude
	 * 
	 * @param   void
	 * @return	double - The locations latitude
	 */
	public double getLatitude() 
	{
		// make sure the model is loaded
		this.load();
		
		return latitude;
	}

	/**
	 * Set the location's latitude
	 * 
	 * @param   latitude - double - The locations latitude
	 * @return	void
	 */
	public void setLatitude(double latitude) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.latitude = latitude;
	}

	/**
	 * Get the location's longitude
	 * 
	 * @param   void
	 * @return	double - The locations longitude
	 */
	public double getLongitude() 
	{
		// make sure the model is loaded
		this.load();
		
		return longitude;
	}

	/**
	 * Set the location's longitude
	 * 
	 * @param   longitude - double - The locations longitude
	 * @return	void
	 */
	public void setLongitude(double longitude) 
	{
		// mark the model as updated
		this.updated = true;
		
		this.longitude = longitude;
	}

}
